<?php
defined('IN_IA') or exit('Access Denied');

function _calc_current_frames2(&$frames) {
	global $_W,$_GPC;
	if(!empty($frames) && is_array($frames)) {
		foreach($frames as &$frame) {
			foreach($frame['items'] as &$fr) {
				if(count($fr['actions']) == 2){
					if($fr['actions']['1'] == $_GPC[$fr['actions']['0']]){
						$fr['active'] = 'active';
					}
				}elseif(count($fr['actions']) == 4){
					if($fr['actions']['1'] == $_GPC[$fr['actions']['0']] && $fr['actions']['3'] == $_GPC[$fr['actions']['2']]){
						$fr['active'] = 'active';
					}
				}else{
					$query = parse_url($fr['url'], PHP_URL_QUERY);
					parse_str($query, $urls);
					if(defined('ACTIVE_FRAME_URL')) {
						$query = parse_url(ACTIVE_FRAME_URL, PHP_URL_QUERY);
						parse_str($query, $get);
					} else {
						$get = $_GET;
					}
					if(!empty($_GPC['a'])) {
						$get['a'] = $_GPC['a'];
					}
					if(!empty($_GPC['c'])) {
						$get['c'] = $_GPC['c'];
					}
					if(!empty($_GPC['do'])) {
						$get['do'] = $_GPC['do'];
					}
					if(!empty($_GPC['ac'])) {
						$get['ac'] = $_GPC['ac'];
					}
					if(!empty($_GPC['status'])) {
						$get['status'] = $_GPC['status'];
					}
					if(!empty($_GPC['op'])) {
						$get['op'] = $_GPC['op'];
					}
					if(!empty($_GPC['m'])) {
						$get['m'] = $_GPC['m'];
					}
					$diff = array_diff_assoc($urls, $get);
				
					if(empty($diff)) {
						$fr['active'] = 'active';
					}else{
						$fr['active'] = '';
					}
				}
			}
		}
	}
}

function get_top_menus(){
	$frames = array();
	
    $frames['bind']['title'] = '<i class="fa fa-laptop"></i>&nbsp;&nbsp; 绑定';
	$frames['bind']['url'] = web_url('bind/bind/cabinet_admin');
	$frames['bind']['active'] = 'bind';
    
	return $frames;
}

function getbindFrames(){
	global $_W;
	$frames = array();
	$frames['bind']['title'] = '<i class="fa fa-list"></i>&nbsp;&nbsp; 绑定';
	$frames['bind']['items'] = array();
	
	$frames['bind']['items']['count']['url'] = web_url('bind/bind/cabinet_admin');
	$frames['bind']['items']['count']['title'] = '柜子与管理员';
	$frames['bind']['items']['count']['actions'] = array();
	$frames['bind']['items']['count']['active'] = '';

	return $frames;
}
